<%--
  Created by IntelliJ IDEA.
  User: 86151
  Date: 2024/08/14
  Time: 22:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增图书</title>
    <%
        String base = request.getContextPath()+"/";
        String url = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+base;
    %>
    <base href="<%=url%>">
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //窗体加载后 提交按钮的单击时间，发送异步请求
            $("[type='button']").click(function () {
                var BookName=$("[name='BookName']").val();
                var BookAuthor = $("[name='BookAuthor']").val();
                var val = $("[name='BookPublish']").val();
                var val1 = $("[name='BookPage']").val();
                var val2 = $("[name='BookPrice']").val();
                var val3 = $("[name='CreateDate']").val();
                $.get("book/addBook",{"BookName":BookName,"BookAuthor":BookAuthor,"val":val,"val1":val1,"val2":val2,"val3":val3},
                    function (str) {
                    JSON.stringify(str);
                    if(str){
                        alert("添加成功");
                    }else{
                        alert("添加失败");
                    }
                });
            });
        });
    </script>
</head>
<body>
<a href="index.jsp">返回</a>
    <h1>新加图书</h1>
        书名：<input type="text" name="BookName"><br>
        作者：<input type="text" name="BookAuthor"><br>
        出版社：<input type="text" name="BookPublish"><br>
        页数：<input type="text" name="BookPage"><br>
        价格：<input type="text" name="BookPrice"><br>
        时间：<input type="text" name="CreateDate"><br>
        <input type="button" value="提交"/><br/>




</body>
</html>
